import time
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.wait import WebDriverWait

d=webdriver.Chrome()
d.maximize_window()
d.get('https://test.rabbitpre.com/')
d .find_element_by_id('g-j-signin-btn').click()
d .switch_to.frame('sso')
d .find_element_by_xpath('/html/body/div[1]/div/div[2]/div[1]/span[2]').click()
d .find_element_by_xpath('/html/body/div[1]/div/div[2]/div[3]/div[1]/input').send_keys('1xxxxx')
d .find_element_by_xpath('/html/body/div[1]/div/div[2]/div[3]/div[2]/input').send_keys('xxxxxx6')
d .find_element_by_xpath('/html/body/div[1]/div/div[2]/div[3]/button').click()
time.sleep(2)

try:
    Error = WebDriverWait(d, 5, 0.5).until_not(lambda x: x.find_element_by_css_selector('div.login-form span.error-tips'))
except TimeoutException:
    d.save_screenshot('screen01.png')
else:
    print('登录成功!')
